<template>
    <div id="AsnDetail">
        <div class="detail">
            <v-navMenu
                    :detailNav="detailNav"
                    :menuData="menuData"
                    @setMentActive="setMentActive"
            ></v-navMenu>
            <component :inputData="detailData" :is="currentComponent"></component>
        </div>
    </div>
</template>

<script>
    import navMenu from "commons/NavMenu";
    import baseMixin from "@/mixins/BaseMixin";

    export default {
        name: "AsnDetail",
        mixins: [baseMixin],
        data() {
            return {
                newFlag: false,
                selectData: {},
                detailData: {},
                menuData: [
                    {label: this.$t('config.general'), index: "1"},
                    {label: this.$t('config.address'), index: "2"},
                    {label: this.$t('config.payAdress'), index: "3"},
                    {label: this.$t('config.other'), index: "4"},
                ],
                detailNav: "1",
                componentConfig: [
                    {
                        name: "Common",
                        label: this.$t('config.general'),
                        component: () => import('./page/Common.vue')
                    },
                    {
                        name: "Address",
                        label: this.$t('config.address'),
                        component: () => import('./page/Address.vue')
                    },
                    {
                        name: "Payeraddress",
                        label: this.$t('config.payAdress'),
                        component: () => import('./page/Payeraddress.vue')
                    },
                    {
                        name: "Other",
                        label: this.$t('config.other'),
                        component: () => import('./page/Other.vue')
                    }
                ]
            }
        },
        computed: {
            currentComponent() {
                return this.componentConfig[this.detailNav - 1].component;
            }
        },
        methods: {
            setMentActive(key) {
                this.detailNav = key;
            },
            async getData() {
                try {
                    let res = await this.$api.get(`/queryStorer12/${this.selectData.storerkey}/${this.selectData.type}`);
                    
                        this.detailData = res.bean;
                    
                } catch (e) {
                    this.$message.error(e);
                }
            },
        },
        mounted() {
            this.newFlag = this.$store.state.newFlag;
            if (Object.keys(this.$store.state.skip).length !== 0) {
                let data = this.$store.state.skip;
                this.detailData = data.detail;
                this.selectData = data.routeData;
                this.detailNav = data.detailNav;
                this.newFlag = data.newFlag;
                this.$store.commit("setNewFlag", data.newFlag);
            } else if (this.newFlag) {
                this.detailData = {
                    type: "1",
                    sourceversion: 0,
                    cartongroup: "STD",
                    pickcode: "NSPFIFO",
                    createpataskonrfreceipt: "0",
                    calculateputawaylocation: "2",
                    defaultstrategy: "STD",
                    defaultskurotation: "LOT",
                    defaultrotation: "1",
                    rollreceipt: "1",
                    receiptvalidationtemplate: " ",
                    allowautocloseforpo: "1",
                    allowautocloseforasn: "1",
                    allowautocloseforps: "1",
                    allowsystemgeneratedlpn: "1",
                    allowduplicatelicenseplates: "1",
                    allowcommingledlpn: "1",
                    allowsinglescanreceiving: "1",
                    lpnlength: 6,
                    applicationid: "00",
                    sscc1stdigit: 0,
                    uccvendornumber: " ",
                    caselabeltype: "STD",
                    autoprintlabellpn: "1",
                    autoprintlabelputaway: "1",
                    lpnstartnumber: " ",
                    nextlpnnumber: " ",
                    lpnrollbacknumber: " ",
                    autocloseasn: "0",
                    autoclosepo: "0",
                    defaultreturnsloc: "RETURN",
                    defaultqcloc: "QC",
                    piskuxloc: "0",
                    ccskuxloc: "0",
                    ccdiscrepancyrule: "STD",
                    ccadjbyrf: "0",
                    orderbreakdefault: "0",
                    skusetuprequired: "0",
                    defaultqclocout: "PICKTO",
                    kship_Carrier: 0,
                    reqreasonshortship: 0,
                    containerexchangeflag: 0,
                    cartonizeftdflt: "0",
                    defftlabelprint: "0",
                    deffttaskcontrol: "0",
                    tempforasn: "N",
                    mixedlpnputstrategy: "STD",
                    rtxneedweight: 0
                }
            } else {
                this.selectData = this.$store.state.routeData;
                this.getData();
            }
        },
        watch: {},
        components: {
            "v-navMenu": navMenu
        },
    }
</script>

<style scoped>

</style>
